<?
include_once 'lib/facebook.php';
include_once 'includes/config.php';
include_once 'includes/dbconnect.php';

$question_id = $_POST['question_id'];
$answer = $_POST['answer'];
$fb_id = $_SESSION['fb_id'];
$check_action = $_POST['check_action'];

$chk = mysql_query("select * from tbl_answer where question_id='$question_id' and fb_id='$fb_id' and answer='$answer'");

if ($check_action == "checked") {
    if(mysql_num_rows($chk)==0){ 
        mysql_query("insert into tbl_answer(question_id,fb_id,answer,created_datetime)values('$question_id','$fb_id','$answer',now())");
    } 
}else{
    mysql_query("delete from tbl_answer where question_id='$question_id' and fb_id='$fb_id' and answer='$answer'");
}

?>
